from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
from blog.views import FlexView
import os

class MainPage(webapp.RequestHandler):
    def get(self):
        self.redirect('/blog')

class Blog(webapp.RequestHandler):
    def get(self):
        blog = FlexView('flex-pyamf-blog','blog','runtime/settings_blog.xml')
        self.response.out.write(template.render(blog.path(), blog.template_values()))

class Admin(webapp.RequestHandler):
    def get(self):
        admin = FlexView('flex-pyamf-blog: admin', 'admin', 'runtime/settings_admin.xml')
        self.response.out.write(template.render(admin.path(), admin.template_values()))
                
application = webapp.WSGIApplication(
    [
        ('/', MainPage),
        ('/blog', Blog),
        ('/admin', Admin)
    ], debug=True)


def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
